<?php

	namespace app\common\model\goods;

	use think\Model;

	class Product extends Model{

		// 表名
		protected $name = 'goods_product';
		// 自动写入时间戳字段
		protected $autoWriteTimestamp = 'int';
		// 定义时间戳字段名
		protected $createTime = 'createtime';
		protected $updateTime = 'updatetime';

		public static function config($name){
			$json = self::where(['name' => $name])->value('config');
			$config_array = $json ? json_decode($json, true) : [];
			$config = [];
			foreach($config_array as $k=>$v){
				$config[$v['key']] = $v['value'];
			}
			return $config;
		}
	}